<template>
  <view>
    <view class="paddingL15" style="padding-top: 32rpx">
      <view style="position: relative;width: 100%">
        <view style="position:absolute;width: 100%;height: 300rpx">
          <image src="/pagesWater/static/usage.jpg" style="width: 100%;height: 300rpx"></image>
        </view>
        <view class="paddingL15" style="position: relative;z-index: 9;padding-top: 40rpx;color: #FFFFFF;margin-bottom: 60rpx">
          <view>
            <view style="font-size: 26rpx;opacity: 0.8">可用查询次数</view>
            <view>
              <text v-if="sharObj.enableUnlimited || sharObj.enableWhiteList" style="font-size: 42rpx;font-weight: 600;">无限次</text>
              <view v-else>
                <text style="font-size: 56rpx;font-weight: bold;margin-right: 6rpx">{{ sharObj.availQueryNum }}</text>次
              </view>
            </view>
          </view>
          <view class="row topCard" v-if="sharObj.enableUnlimited || sharObj.enableWhiteList" :style="{ 'margin-top': (sharObj.enableUnlimited || sharObj.enableWhiteList) ? '90rpx' : '70rpx'}">
            <view>
              <text>累计使用次数</text>
              <text>{{ sharObj.usedQueryNum }}次</text>
            </view>
            <view>
              <text>邀请查询次数</text>
              <text>{{ sharObj.freeSpreadNum }}次</text>
            </view>
          </view>
          <view class="row topCard" v-else :style="{ 'margin-top': (sharObj.enableUnlimited || sharObj.enableWhiteList) ? '90rpx' : '70rpx'}">
            <view>
              <text>永久查询次数</text>
              <text>{{ sharObj.availPermanentNum }}次</text>
            </view>
            <view>
              <text>今日赠送可用次数</text>
              <text>{{ sharObj.availNowTempNum }}次</text>
            </view>
          </view>

        </view>
      </view>

      <view class="userCard paddingL15">
        <view class="row">
          <text></text>
          <text>新用户次数</text>
        </view>
        <view class="row cardItem">
          <view>
            <view>{{ sharObj.freeSignNum }}</view>
            <view>总查询次数</view>
          </view>
          <view style="width: 1px;height: 65rpx;background-color: #DDDDDD"></view>
          <view>
            <view>{{ sharObj.usedSignNum }}</view>
            <view>已使用次数</view>
          </view>
          <view style="width: 1px;height: 65rpx;background-color: #DDDDDD"></view>
          <view>
            <view>{{ sharObj.availSignNum }}</view>
            <view>可用查询次数</view>
          </view>
        </view>
      </view>
      <view class="userCard paddingL15">
        <view class="row" style="justify-content: space-between">
          <view class="row">
            <text></text>
            <text>邀请好友</text>
          </view>
          <view style="color: #666666;font-size: 26rpx">
            已使用：{{ sharObj.usedSpreadNum }}次
          </view>
        </view>
        <view class="row cardItem">
          <view>
            <view>{{ sharObj.spreadCount }}</view>
            <view>邀请好友人数</view>
          </view>
          <view style="width: 1px;height: 65rpx;background-color: #DDDDDD"></view>
          <view>
            <view>{{ sharObj.freeSpreadNum }}</view>
            <view>获得查询次数</view>
          </view>
          <view style="width: 1px;height: 65rpx;background-color: #DDDDDD"></view>
          <view>
            <view>{{ sharObj.availSpreadNum }}</view>
            <view>可用查询次数</view>
          </view>
        </view>
      </view>
      <view v-if="!sharObj.enableWhiteList && !sharObj.enableUnlimited" class="userCard paddingL15">
        <view class="row" style="justify-content: space-between">
          <view class="row">
            <text></text>
            <text>每日赠送</text>
          </view>
          <view style="color: #666666;font-size: 26rpx">
            累计使用次数：{{ sharObj.usedTempNum }}次
          </view>
        </view>
        <view class="row cardItem">
          <view>
            <view>{{ sharObj.freeTempNum }}</view>
            <view>每日赠送次数</view>
          </view>
          <view style="width: 1px;height: 65rpx;background-color: #DDDDDD"></view>
          <view>
            <view>{{ sharObj.usedNowTempNum }}</view>
            <view>已使用次数</view>
          </view>
          <view style="width: 1px;height: 65rpx;background-color: #DDDDDD"></view>
          <view>
            <view>{{ sharObj.availNowTempNum }}</view>
            <view>可用查询次数</view>
          </view>
        </view>
      </view>
      <!--无限-->
      <view v-if="sharObj.enableUnlimited || sharObj.enableWhiteList" class="userCard paddingL15">
        <view class="row">
          <text></text>
          <text>白名单</text>
        </view>
        <!--白名单查询-->
        <view class="row cardItem" v-if="!sharObj.enableUnlimited" style="justify-content: space-around">
          <view>
            <view style="font-size: 32rpx">无限次</view>
            <view>可用查询次数</view>
          </view>
          <view style="width: 1px;height: 65rpx;background-color: #DDDDDD"></view>
          <view>
            <view>{{ sharObj.usedWhiteNum }}</view>
            <view>已使用次数</view>
          </view>
        </view>
        <!--开启无限次查询-->
        <view class="row cardItem" v-if="sharObj.enableUnlimited" style="justify-content: space-around">
          <view>
            <view style="font-size: 32rpx">无限次</view>
            <view>可用查询次数</view>
          </view>
          <view style="width: 1px;height: 65rpx;background-color: #DDDDDD"></view>
          <view>
            <view>{{ sharObj.usedUnlimitedNum }}</view>
            <view>已使用次数</view>
          </view>
        </view>
      </view>
    </view>
    <loading :show="loading"></loading>
  </view>
</template>

<script>
import {getShareApi} from "@/api/home";
import share from "@/utils/share";

export default {
  data () {
    return {
      sharObj: {},
      loading: false
    }
  },
  onLoad() {
    this.getUserUse()
	// #ifdef H5
	share.getShareConfig({}, this.$WXMENU);
	// #endif
    
  },
  methods: {
    getUserUse() {
      this.loading = true
      getShareApi().then(res => {
        if (res.code === 200) {
          this.sharObj = res.data
        }
      }).finally(() => {
        this.loading = false
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.userCard {
  width: 100%;
  height: 244rpx;
  border-radius: 16rpx;
  background-color: #FFFFFF;
  padding-top: 30rpx;
  margin-bottom: 20rpx;
  view {
    margin-bottom: 20rpx;
    &:nth-child(1) {
      justify-content: flex-start;
      text {
        &:nth-child(1) {
          width: 10rpx;
          height: 32rpx;
          background-color: #488AFD;
          border-radius: 5rpx;
          display: inline-block;
          margin-right: 12rpx;
        }
        &:nth-child(2) {
          font-size: 32rpx;
          color: #111111;
          font-weight: 500;
        }
      }
    }
    &:nth-child(2) {
      text-align: center;
    }
  }
}
.cardItem {
  view {
    view {
      &:nth-child(1) {
        font-size: 44rpx;
        font-weight: bold;
      }
      &:nth-child(2) {
        font-size: 24rpx;
        color: #999999;
      }
    }
  }
}
.topCard {
  view {
    text {
      &:nth-child(1) {
        font-size: 26rpx;
        opacity: 0.8;
      }
      &:nth-child(2) {
        font-size: 32rpx;
        font-weight: bold;
        margin-left: 6rpx;
      }
    }
  }
}
</style>